#ifndef _STRLIB_H
#define _STRLIB_H

void memset(UCHAR *addr, UCHAR value, int len);
void memcpy(UCHAR *dst, UCHAR *src, int len);
int memcmp(UCHAR *str, UCHAR *str2, int len);
int memcmpv(UCHAR *str1, UCHAR value, int len);

int abs(int i);
int strcmp(char * str1, char * str2);
int strncmp(char *str1, char *str2, int len);
char * strcat(char * str1, char * str2);
int strlen(char * str);
char * strcpy(char * dest, char * src);
void itoa(int i, char *str);
int atoi(char *str);
USHORT make_short(UCHAR *str);
USHORT make_h_short(UCHAR *str);
void depart_short(USHORT us, UCHAR *str);
void depart_h_short(USHORT us, UCHAR *str);
ULONG make_long(UCHAR *str);
ULONG make_h_lng(UCHAR *str);
void depart_long(ULONG ul, UCHAR *str);
void flex_itoa(int i, char *str, int span1, int span2);
void flex_hextoa(ULONG ul, char *str, int span1, int span2);
void print_charbuf(UCHAR *buf, int len);
void hextobcd(unsigned char *str, int len);
void hex2toa_rev(UCHAR uc, char *str);
void BcdToHex(unsigned char *str, int len);
int atoip(char *str, ULONG *pip);
void iptoa(ULONG ip, char *str);
ULONG htonl(ULONG ul);
void depart_long_htol(ULONG ul, UCHAR *str);

USHORT cal_crc(UCHAR *pbuf, ULONG count);
void strtobcdn(char *str, unsigned char *bcd, int maxlen);
void strtobcd(char *str, unsigned char *bcd, int maxlen);
int ltobcd(unsigned long ul, unsigned char *bcd, int maxlen);
int ustrcmp1(char *str1, char *str2, int len, char reverse);
int max3(ULONG a,ULONG b,ULONG c);
int min3(ULONG a,ULONG b,ULONG c);
int make_h_int(UCHAR *str);

static __inline void ReverseBuf(unsigned char* buf, int len)
{
	int i = 0, j = len/2;
	unsigned char tmp;

	for(i=0; i<j; i++)
	{
		tmp = buf[i];
		buf[i] = buf[len-1-i];
		buf[len-1-i] = tmp;
	}
}
#endif/*_STRLIB_H*/

